package com.kfh.ybracelet.my;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.kfh.ybracelet.R;
import com.kfh.ybracelet.base.BaseActivity;


/**
 * 添加老人
 * Created by Administrator on 2015/8/13.
 */
public class AddBabyActivity extends BaseActivity {

    private Intent intent;
    private boolean canCancle;//是否可以退出

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_add_baby);
//        mApplication.addActivity(this);

        canCancle = getIntent().getBooleanExtra("cancle", true);

        init();

    }

    private void init() {

        ImageView iv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);
        tv_title.setText(getResources().getString(R.string.add));
        TextView tv_entrybaby_code = (TextView) findViewById(R.id.tv_entrybaby_code);
        TextView tv_createbaby_space = (TextView) findViewById(R.id.tv_createbaby_space);

        tv_createbaby_space.setOnClickListener(this);
        iv_left.setOnClickListener(this);
        tv_entrybaby_code.setOnClickListener(this);

    }

    @Override
    public void onBackPressed() {

        if (!canCancle) {
            showToast("请先添加老人");
            return;
        }

        super.onBackPressed();
    }

    @Override
    public void widgetClick(View v) {

        switch (v.getId()) {

            case R.id.iv_left:

                if (!canCancle) {
                    showToast("请先添加老人");
                    return;
                }

                finish();
                break;

            case R.id.tv_entrybaby_code://输入邀请码

                intent = new Intent(this, EntryCodeActivity.class);
                startActivity(intent);
                break;

            case R.id.tv_createbaby_space://创建新的空间

                intent = new Intent(this, CreateBabySpaceActivity.class);
                startActivity(intent);
                break;
        }
    }
}